﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PharmacyBussinesEntities;

namespace PharmacyRepositoy.Mapping
{
    public class LoteMap:EntityTypeConfiguration<Lote>
    {
        public LoteMap()
        {
            this.HasKey(p => p.Id);

            this.Property(p => p.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(p => p.Descripcion)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(p => p.FechaCanje)
                .IsRequired();
            this.Property(p => p.FechaVencimiento)
                .IsRequired();

            this.Property(p => p.PrecioCosto)
                .HasPrecision(9, 2);

            this.Property(p => p.PrecioVenta)
                .HasPrecision(9, 2);

            this.Property(p => p.Cantidad)
                .IsRequired();

            this.ToTable("LOTE");


            this.HasRequired(p=>p.Producto)
                .WithMany()
                .HasForeignKey(p=>p.IdPoducto)
                .WillCascadeOnDelete(false);


        }  
    }
}
